//
//  RSPopViewController.m
//  iAccountBook
//
//  Created by 侯伟 on 2020/1/13.
//  Copyright © 2020 侯伟. All rights reserved.
//

#import "RSPopViewController.h"

@interface RSPopViewController ()

@end

@implementation RSPopViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.modalPresentationStyle = UIModalPresentationOverCurrentContext;
//    self.modalPresentationStyle = 0;
    self.view.backgroundColor = UIColor.clearColor;
    self.popView.layer.cornerRadius = 12;
}

- (void)presentOverViewController:(UIViewController*)viewController{
    
    __weak UIView* weakView = self.view;
    __weak UIView* weakPopView = self.popView;
    weakPopView.alpha = 0;
    
    [Queue asyncMain:^{
        [viewController presentViewController:self animated:NO completion:^{
            weakPopView.transform = CGAffineTransformMakeScale(0, 0);
            [UIView animateWithDuration:0.25 animations:^{
                weakView.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0x66/255.0];
                weakPopView.alpha= 1;
                weakPopView.transform = CGAffineTransformMakeScale(1, 1);
            }];
        }];
    }];

    
}

- (void)dismissAlertController:(void (^)(void))completion{

    [UIView animateWithDuration:0.25 animations:^{
        self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
        self.popView.alpha= 0;
        self.popView.transform = CGAffineTransformMakeScale(0, 0);
        
    } completion:^(BOOL finished) {
        [self dismissViewControllerAnimated:NO completion:completion];
    }];
}


@end
